package fw_cache

import (
	"github.com/dgraph-io/ristretto"
)

var cacheHandle *ristretto.Cache

func CacheInit() error {
	var err error
	cacheHandle, err = ristretto.NewCache(&ristretto.Config{
		NumCounters: 1e7,     // number of keys to track frequency of (10M).
		MaxCost:     1 << 30, // maximum cost of cache (1GB).
		BufferItems: 64,      // number of keys per Get buffer.
	})
	if err != nil {
		return err
	}
	return nil
}

func GetCacheHandler() *ristretto.Cache {
	return cacheHandle
}
